<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../../../commons/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>药品盘点</title>
<link rel="stylesheet" href="${ctx}/static/css/pintuer.css">
    <link rel="stylesheet" href="${ctx}/static/css/admin.css">
    <script src="${ctx}/static/js/jquery.js"></script>
    <script src="${ctx}/static/js/pintuer.js"></script> 
</head>
<body>
<script type="text/javascript">
function sc(id) {
		console.log(id);
	if(id!=null){
		location="fp_delete?id="+id
	}else{
		alert("发票号为空或者发票号不存在!");
		return
	}	
	
}
function cx(){
	var sh=$('#test option:selected').val();
	var fpnumber=document.getElementById('fpnumber').value;
	location ='fp_search?fpnumber='+fpnumber+"&sh="+sh;
}
function selected(){
    var allcheck=document.getElementById("all");  //获取 全选check 的id
    var othercheck=document.getElementsByName("box"); //获取数组名称为fkcheck的 复选框
	for(var i=0;i<othercheck.length;i++){ 
		
		if(allcheck.checked)
			{ othercheck[i].checked=true;}
			
		else
			{ othercheck[i].checked=false;} 
		}
    
    
    }
function plsc(){
	 var chckBox = document.getElementsByName("box");  
     var num = chckBox.length;  
     var ids = "";  
     for(var index =0 ; index<num ; index++){  
         if(chckBox[index].checked){  
             ids += chckBox[index].value + ","; 
            
         }  
     }  
     if(ids!=""){
    	 $.post('dt_fp_delete',{"ids":ids},function(data){
        	 alert("批量删除成功");
        	 location.reload(); 
        	 return
         })
     }else{
    	 alert("请选择批量删除的条目");
    	 return
     }
    
}

function sh(){
	var chckBox = document.getElementsByName("box");  
    var num = chckBox.length;  
    var ids = "";
   
    for(var index =0 ; index<num ; index++){  
        if(chckBox[index].checked){  
            ids += chckBox[index].value + ","; 
        }  
    } 
    
    //var sh=$('#test option:selected').val();
    var sh=$('input[name="sh"]').val();
    var sh_name="${username }";
    if(ids!=""){
    	if(sh=="未审核"){
    		$.post('zt_update',{"ids":ids,"sh_name":sh_name},function(data){
       	   	 alert("审核成功");
       	   	 location.reload(); 
       	   	 return
       	    })
    	}else{
    		alert("请选择未审核的审核");
    		return
    	}
    }else{
    	alert("你还没有选中审核的发票号");
    	return
    }
   
}
</script>
<form method="post" action="excel">
	<div class="panel admin-panel">
		<div class="panel-head">
			<!-- <strong class="icon-reorder"> 挂号管理</strong> -->
			<select name="copynum" style="padding:5px 15px; border:1px solid #ddd;" onchange="change(this.value)">
            <option value="1" selected="selected">药品入库</option>
            <option value="2">药品调价</option>
            <option value="3">药品报损</option>
            <option value="4">药库退货</option>
            <option value="4">药品分装</option>
            <option value="4">盈余短缺</option>
          	</select>
			<div style="float: right;">
				<a href="${ctx}/business/depot/daily/zy_medicine" class="button border-main">新增</a>
				<a class="button border-main" href="JavaScript:;" onclick="sh()">审核</a>
				<button class="button border-main excel" type="submit">导出Excel</button>
			    <a class="button border-main" href="inventory">刷新</a>
			</div>
			<div style="clear: both;"></div>
		</div>
			<ul class="search" style="padding-left:10px;">
				<li>
					<select name="copynum" style="padding:5px 15px; border:1px solid #ddd;" onchange="change(this.value)">
            			<option value="5" selected="selected">当前单据库</option>
            			<option value="6">历史单据库</option>
          			</select>
				</li>
				<li>
					<input  class="input" name="fpnumber" value="" placeholder="请输入发票号" id="fpnumber" />
				</li>
				<li>
					<input  class="input" name="ID_search" value="" placeholder="发票号" id="dj" readOnly="true"/>
				</li>
				<li>
					<select name="copynum" id="test" style="padding:5px 15px; border:1px solid #ddd;wi" >
            			<option value="已审核">已审核</option>
            			<option value="未审核">未审核</option>
          			</select>
				</li>
				<li>
					<a class="button border-main" href="JavaScript:;" onclick="cx()"> 查询</a>
				</li>
				<li>
					<a href="inventory">清除搜索</a>
				</li>
			</ul>
		</div>
		<table class="table table-hover text-center">
		<tr style="background-color:#CCECED;">
		  	 	 		<th><input type="checkbox" id="all" value="全选" onclick="selected()">&nbsp;</th>
						<th>操作</th>
						<th title="点击排序" onclick="PIAIXU(this,1,'xx.djbh' )"><span class="spanpx">单据编号</span> </th>
						<th title="点击排序" onclick="PIAIXU(this,1,'dw.GHDWMC' )"><span class="spanpx">供货单位</span></th>
						<th title="点击排序" onclick="PIAIXU(this,1,'xx.RCRQ' )"><span class="spanpx">入出日期</span></th>
						<th>入库科室</th>
						<th>录入人员</th>
						<th>单据状态</th>
						<th>审核人员</th>
						<th title="点击排序" onclick="PIAIXU(this,1,'xx.SHRQ')"><span class="spanpx">审核日期</span></th>
						
		  		  </tr>
		<c:forEach items="${fp_list }" var="list">
			<tr>
				<td style="text-align:left; padding-left:20px;border-bottom: 1px solid #ddd;">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="box" id="${list.id}" value="${list.id}" > </td>
				<td style="text-align:left; padding-left:20px;border-bottom: 1px solid #ddd;"><a class="button border-main" href="JavaScript:;" onclick="sc(${list.id})">删除</a></td>
				<td style="text-align:left; padding-left:20px;border-bottom: 1px solid #ddd;color:blue;"><input type="hidden" name="id" value="${list.fpnumber}" /> ${list.fpnumber}</td>
				<td style="border-bottom: 1px solid #ddd;"><input type="hidden" name="category" value="${list.company_name }"/>${list.company_name }</td>
				<td style="border-bottom: 1px solid #ddd;color:red;"><input type="hidden" name="name" value="${list.sc_date }"/>${list.sc_date }</td>
				<td style="border-bottom: 1px solid #ddd;color:#FF1493"><input type="hidden" name="do_name" value="${list.d_name }"/>${list.d_name }</td>
				<td style="border-bottom: 1px solid #ddd;"><input type="hidden" name="do_name" value="${list.ad_name }"/>${list.ad_name }</td>
				<td style="border-bottom: 1px solid #ddd;color: #9932CC"><input type="hidden" name="sh"  value="${list.sh }"/>${list.sh }</td>
				<td style="border-bottom: 1px solid #ddd;"><input type="hidden" name="fee" value="${list.sh_name }"/>${list.sh_name }</td>
				<td style="border-bottom: 1px solid #ddd;color:red;"><input type="hidden" name="fee" value="${list.sh_date}"/>${list.sh_date }</td>
				<td style="border-bottom: 1px solid #ddd;"><input type="hidden" name="deal" value=""/></td>
			</tr>
		</c:forEach>
			<tr>
				<td>
					<c:if test="${fp_list!=null}" >
					<a style="cursor:pointer;color: red" onclick="plsc()">批量删除</a>
					</c:if>
				</td>
			</tr>
		
		</table>
	
</form>

</body>
<script type="text/javascript">
function change(data){
	console.log(data);
	if(data==1){
		window.location="inventory";
	}
	if(data==2){
		window.location="inventory1";
	}
	if(data==3){
		window.location="inventory2";
	}
	if(data==4){
		window.location="inventory3";
	}

   	
};
</script>
</html>